//
//  YGKJTabbarVC.m
//  新项目
//
//  Created by 刘耀宗 on 2016/10/21.
//  Copyright © 2016年 刘耀宗. All rights reserved.
//

#import "YGKJTabbarVC.h"
#import "ZZCarVC.h"
#import "ZZFirstVC.h"
#import "ZZOrderVC.h"
#import "YGKNavigationVC.h"
#import "ZZDataAnalysisVC.h"
#import "ChooseCarController.h"
#import "ZZSettingVC.h"
@interface YGKJTabbarVC ()

@end

@implementation YGKJTabbarVC

- (void)viewDidLoad {
    [super viewDidLoad];
    //通过appearance统一设置所有UITabBarItem的文字属性
    // 后面带有UI_APPEARANCE_SELECTOR的方法，都可以通过appearance对象来统一设置
    
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
//    attrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
    
    NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];
    selectedAttrs[NSFontAttributeName] = attrs[NSFontAttributeName];
    selectedAttrs[NSForegroundColorAttributeName] = CcColor(69, 127, 181);
    
    UITabBarItem *item = [UITabBarItem appearance];
    [item setTitleTextAttributes:attrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];
    
    //添加子控制器
    // 添加子控制器
    ZZFirstVC *vc01 = [[ZZFirstVC alloc] init];
    vc01.tabBarItem.title = @"首页";
    
    vc01.tabBarItem.image = [UIImage imageNamed:@"ic_tab_home"];
    vc01.tabBarItem.selectedImage = [[UIImage imageNamed:@"ic_tab_home_pressed"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    
    YGKNavigationVC *navi01=[[YGKNavigationVC alloc]initWithRootViewController:vc01];
    [self addChildViewController:navi01];
    
    ZZDataAnalysisVC *vc02 = [[ZZDataAnalysisVC alloc]init];
    vc02.tabBarItem.title = @"数据统计";
    vc02.tabBarItem.image = [[UIImage imageNamed:@"ic_tab_list"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc02.tabBarItem.selectedImage = [[UIImage imageNamed:@"ic_tab_list_pressed"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc02.view.backgroundColor = [UIColor whiteColor];
    YGKNavigationVC *navi02 = [[YGKNavigationVC alloc]initWithRootViewController:vc02];
    [self addChildViewController:navi02];
    
    ZZSettingVC *vc03 = [[ZZSettingVC alloc] init];
    vc03.tabBarItem.title = @"更多设置";
    vc03.tabBarItem.image = [UIImage imageNamed:@"ic_tab_car"];
    vc03.tabBarItem.selectedImage = [[UIImage imageNamed:@"ic_tab_car_pressed"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc03.view.backgroundColor = [UIColor whiteColor];
    
    
    YGKNavigationVC *navi03=[[YGKNavigationVC alloc]initWithRootViewController:vc03];
    [self addChildViewController:navi03];
    self.tabBar.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.8];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
/**
 *  初始化子控制器
 *    ChildVc       控制器
 *     title        标题
 *     image        点击图片
 *  selectedImage   被选择图标
 */
-(void)setupChildVc:(UIViewController *)vc
              title:(NSString *)title
              image:(NSString *)image
      selectedImage:(NSString *)selectedImage
{
    //设置文字和图片
    vc.tabBarItem.title=title;
    vc.tabBarItem.badgeColor=CcColor(51, 51, 51);
    vc.tabBarItem.image=[UIImage imageNamed:image];
    vc.tabBarItem.selectedImage=[UIImage imageNamed:selectedImage];
    vc.view.backgroundColor=[UIColor colorWithRed:arc4random_uniform(100)/100.0 green:arc4random_uniform(100)/100.0 blue:arc4random_uniform(100)/100 alpha:1.0];
    //添加为子控制器
    [self addChildViewController:vc];
}

@end
